// Copyright (c) Symbian Ltd 2008. All rights reserved.

#ifndef __RPSAPPVIEW_H__
#define __RPSAPPVIEW_H__

// INCLUDES
#include <coecntrl.h>
class CGameScreenManager;
class CGameScreen;

// Key identifiers
const TUint KControllerUp     	= 0x00000001;
const TUint KControllerDown   	= 0x00000002;
const TUint KControllerCentre	= 0x00000004;
const TUint KKey5   			= 0x00000008;

// CLASS DECLARATION
class MAppViewObserver
	{
public:
	virtual void FocusChanged(TBool aFocus)=0;
	virtual void KeyEvent(TUint& aKeyState)=0;
	virtual void DrawGameScreen()=0;
	};


// CLASS DECLARATION
class CRpsAppView : public CCoeControl
	{
	public: // New methods

		/**
		* NewL.
		* Two-phased constructor.
		* Create a CRpsAppView object, which will draw itself to aRect.
		* @param aRect The rectangle this view will be drawn to.
		* @return a pointer to the created instance of CRpsAppView.
		*/
		static CRpsAppView* NewL(MAppViewObserver& aObs, const TRect& aRect );

		/**
		* NewLC.
		* Two-phased constructor.
		* Create a CRpsAppView object, which will draw itself
		* to aRect.
		* @param aRect Rectangle this view will be drawn to.
		* @return A pointer to the created instance of CRpsAppView.
		*/
		static CRpsAppView* NewLC(MAppViewObserver& aObs, const TRect& aRect );

		/**
		* ~CRpsAppView
		* Virtual Destructor.
		*/
		virtual ~CRpsAppView();

	public:  // Functions from base classes

		/**
		* From CCoeControl, Draw
		* Draw this CRpsAppView to the screen.
		* @param aRect the rectangle of this view that needs updating
		*/
		void Draw( const TRect& aRect ) const;

		/**
		* From CoeControl, SizeChanged.
		* Called by framework when the view size is changed.
		*/
		virtual void SizeChanged();
		
		/*
		* From CoeControl, FocusChanged.
		* Called by framework when application focus changes.
		*/
		void FocusChanged(TDrawNow aDrawNow);
			
		/**
		* From CoeControl, OfferKeyEventL.
		* Called by framework when keypad input is received.
		*/
		TKeyResponse OfferKeyEventL(const TKeyEvent &aKeyEvent, TEventCode aType);
			
	private: // Constructors		
		/**
		* ConstructL
		* 2nd phase constructor.
		* Perform the second phase construction of a
		* CRpsAppView object.
		* @param aRect The rectangle this view will be drawn to.
		*/
		void ConstructL(const TRect& aRect);

		/**
		* CRpsAppView.
		* C++ default constructor.
		*/
		CRpsAppView(MAppViewObserver& aObs);
		
	private:
		MAppViewObserver& iObs;
		mutable TUint iKeyState; 		
		CGameScreenManager* iGameScreenMgr;
	};

#endif // __RPSAPPVIEW_H__

// End of File
